<?php

namespace App\Providers;

use App\Models\Post;
use App\Repos\FFMpeger;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->singleton('FFMpeger',function(){
            return new FFMpeger();
        });
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {

        Schema::defaultStringLength(191);
        //所有视图共享变量
        view()->share('author','fcesky');
        ////指定视图间共享变量
        ///单个组件
        view()->composer('partials.sidebar', function ($view) { 
            $view->with('posts', [1,2,3,4,5]); 
        });
        ///多个组件
        //通过数组
        view()->composer(['partials.header', 'partials.footer'], function ($view) { 
            $view->with('posts', [1,2,3,4,5]); 
        });
        //通过通配符
        view()->composer('partials.*', function ($view) { 
            $view->with('posts', [1,2,3,4,5]); 
        });

    }
}
